widget: Fix set_focus_child handling during focus changes
authorOlivier Brunel <jjk@jjacky.com>
Tue, 28 Jan 2014 19:33:09 +0000 (20:33 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 4 Feb 2014 02:25:07 +0000 (21:25 -0500)
10b5ec20 made sure not to set focus_child to NULL all the way up to the
top, but only up to the common ancestor. However, it would never set it
on the common ancestor itself, which would therefore remain with a
focus_child set when it shouldn't.

A manifestation of the bug: focus column headers of a treeview, press Tab.
Now pressing Shift+Tab will go to another widget and not the column
headers, and Tab will (appear to) do nothing, all because the treeview
still has a focus_child set to column headers after a grab_focus().

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
https://bugzilla.gnome.org/show_bug.cgi?id=723402

gtk/gtkwidget.c

index 8795189fa57a937bce2188866663efdf01b2aa23..29157c02f3a8f00f51c6c74689124ceec02fd8c9 100644 (file)
@@ -7533,10 +7533,12 @@ gtk_widget_real_grab_focus (GtkWidget *focus_widget)
 
              if (widget != common_ancestor)
                {
-                 while (widget->priv->parent && widget->priv->parent != common_ancestor)
+                 while (widget->priv->parent)
                    {
                      widget = widget->priv->parent;
                      gtk_container_set_focus_child (GTK_CONTAINER (widget), NULL);
+                     if (widget == common_ancestor)
+                       break;
                    }
                }
            }